package indi.kider.server.sms.api;

import indi.kider.common.model.employee.Tenant;
import indi.kider.common.model.woniubus.LeaseBusQuery;
import indi.kider.common.model.woniubus.TenantInHouse;
import indi.kider.server.sms.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import pers.vankid.common.model.base.CommonResponse;

/**
 * Created by shixj on 2018/6/7.
 */
@RestController
public class SmsController {
    @Autowired
    private SmsService smsService;

    @PostMapping("overdue/water")
    public CommonResponse getOverdueWaterBillList() {
        smsService.getOverdueWaterBillList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }
    @PostMapping("overdue/power")
    public CommonResponse getOverduePowerBillList() {
        smsService.getOverduePowerBillList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }
    @PostMapping("overdue/net")
    public CommonResponse getOverdueNetBillList() {
        smsService.getOverdueNetBillList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }
    @PostMapping("overdue/estate")
    public CommonResponse getOverdueEstateBillList() {
        smsService.getOverdueEstateBillList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }
    @PostMapping("overdue/rental")
    public CommonResponse getOverdueRentalBillList() {
        smsService.getOverdueRentalBillList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }
    @PostMapping("due/rental")
    public CommonResponse getDueRentalBillList() {
        smsService.getDueRentalBillList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }
    @PostMapping("due/rent")
    public CommonResponse getDueRentList() {
        smsService.getDueRentList();
        return CommonResponse.buildDefaultSuccessResponse("");
    }

    /**
     * 模板名称:员工入住提醒(企业管理人员)
     * 短信模板编号：SMS_143610268
     * 模板内容：${companyName}完成自主入住办理，请等登陆窝牛联盟确认。
     * http://localhost:9002/sms/tenantSms
     * post
     * {
     *     tenantName:'王焕才',
     *     phone:'11100'
     * }
     */
    @PostMapping("/tenantSms")
    public CommonResponse tenantSms(@RequestBody TenantInHouse tenantInHouse) {
        try {
            return smsService.tenantSms(tenantInHouse);
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }
    /**
     模板名称:入住提醒(短信通知租客)
     短信模板编号：SMS_143560371
     模板内容：管理人员已确认您的入住信息，请打开小程序，开始使用${houseNum}房间。
     * http://localhost:9002/sms/tenantSuccessSms
     * post
     * {
     *     houseNum:房间号,
     *     phone:'110'
     * }
     */
    @PostMapping("/tenantSuccessSms")
    public CommonResponse tenantSuccessSms(@RequestBody TenantInHouse tenantInHouse) {
        try {
            return smsService.tenantSuccessSms(tenantInHouse);
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }
    /**
     模板名称:入住办理信息提醒(短信通知租客)
     短信模板编号：SMS_143610275
     模板内容：你的入住信息已经被${name1}拒绝，请重新注册。请联系${name2},谢谢合作
     * http://localhost:9002/sms/tenantFailSms
     * post
     * {
     *     phone:'110',
     *     partName:'网吧',
     *     partPhone:'120',
     * }
     */
    @PostMapping("/tenantFailSms")
    public CommonResponse tenantFailSms(@RequestBody TenantInHouse tenantInHouse) {
        try {
            return smsService.tenantFailSms(tenantInHouse);
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }

    /**
     * 退房换房发送短信
     * @param leaseBus
     * @return
     */
    @PostMapping("/shSuccessSms")
    public CommonResponse shSuccessSms(@RequestBody LeaseBusQuery leaseBus) {
        try {
            return smsService.shSuccessSms(leaseBus);
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }


    /**
     * 重置锁密码短信
     * @param tenant
     * @return
     */
    @PostMapping("/resetLockpwdSms")
    public CommonResponse resetLockpwdSms(@RequestBody Tenant tenant) {
        try {
            return smsService.resetLockpwdSms(tenant);
        } catch (Exception e) {
            return CommonResponse.buildExceptionResponse(e);
        }
    }

//    @PostMapping("/sendStableSms")
//    public CommonResponse sendStableSms() {
//        try {
//            return smsService.sendStableSms();
//        } catch (Exception e) {
//            return CommonResponse.buildExceptionResponse(e);
//        }
//    }
}
